package com.kdl.webconfig.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kdl.webconfig.entity.NewsDetail;
import com.kdl.webconfig.mapper.NewsDetailMapper;
import com.kdl.webconfig.service.INewsDetailService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 新闻详情表 服务实现类
 * </p>
 *
 * @author wcj
 * @since 2022-09-14
 */
@Service
public class NewsDetailServiceImpl extends ServiceImpl<NewsDetailMapper, NewsDetail> implements INewsDetailService {

    @Resource
    private NewsDetailMapper newsDetailMapper;

    @Override
    public NewsDetail selectOneByNewsId(Integer newsId) {
        QueryWrapper<NewsDetail> newsDetailQueryWrapper = new QueryWrapper<>();
        newsDetailQueryWrapper.lambda().eq(NewsDetail::getNewsId,newsId);
        return newsDetailMapper.selectOne(newsDetailQueryWrapper);
    }

    @Override
    public int deleteByNewsId(Integer id) {
        QueryWrapper<NewsDetail> newsDetailQueryWrapper = new QueryWrapper<>();
        newsDetailQueryWrapper.lambda().eq(NewsDetail::getNewsId,id);
        return newsDetailMapper.delete(newsDetailQueryWrapper);
    }
}
